

/* Includes ------------------------------------------------------------------*/
#include "stm32f2x7_eth.h"
#include "netconf.h"
#include "main.h"
#include "dns.h"
#include "lwip/tcp.h"
#include "serial_debug.h"

static void dnr_found_callback(const char *name, struct ip_addr *ipaddr, void *callback_arg);

err_t DomainNameResolution(const char *hostname ,struct ip_addr *ipaddr)
{ 
  err_t err;
  err = dns_gethostbyname(hostname, ipaddr, (dns_found_callback)dnr_found_callback, NULL);
  if(err!=ERR_INPROGRESS){
    printf("get host by name err : %d\n",err);
    return err;  
  }else{
    return ERR_OK;
  }
}

void dnr_found_callback(const char *name, struct ip_addr *ipaddr, void *callback_arg)
{
  printf("gethostbyname(%s)==%s\n", (char*)(name),inet_ntoa((struct in_addr){ipaddr->addr}));
}

  